Each party template record contains the following fields:
1) Party-template id: used for referencing party-templates in other files.
The prefix pt_ is automatically added before each party-template id.
2) Party-template name.
3) Party flags. See header_parties.py for a list of available flags.
4) Menu. ID of the menu to use when this party is met. The value 0 uses the default party encounter system.
5) Faction
6) Personality. See header_parties.py for an explanation of personality flags.
7) List of stacks. Each stack record is a tuple that contains the following fields:
7.1) Troop-id.
7.2) Minimum number of troops in the stack.
7.3) Maximum number of troops in the stack.
7.4) Member flags(optional). Use pmf_is_prisoner to note that this member is a prisoner.
Note: There can be at most 6 stacks.
The file module_party_templates.py begins with the usual Python list: party_templates = [, followed by several templates that are hardwired into the game and should not be edited. You'll notice that the tuples in module_party_templates.py are very similar to those in module_parties.py, but the two are not interchangeable. Look for example at the following party template:
("village_farmers","Village Farmers",icon_peasant|pf_civilian,0,fac_innocents,merchant_personality,[(trp_farmer,5,10),(trp_peasant_woman,3,8)]),
It is a template which we all have encountered in-game. Parties of this template will be called "farmers", they are marked as civilians, they will behave cowardly in-game, and each of them has two troop stacks made up of farmers and peasant women. Breaking down the tuple fields yields:e
("town_1","Sargoth", icon_town|pf_town, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(-1.55, 66.45),[], 170),
This tuple places the town of Sargoth on the map. Sargoth's various qualities are set in the appropriate fields which can be broken down as follows:
1) Party-template id = "village_farmers"
2) Party-template name = "Village Farmers"
3) Party flags = icon_peasant, pf_civilian
4) Menu = 0
5) Faction = fac_innocents
6) Personality = merchant_personality
7) List of stacks:
7.1) Troop-id = trp_farmer, trp_peasant_woman
7.2) Minimum number of troops in the stack = 5 farmers, 3 peasant women
7.3) Maximum number of troops in the stack = 10 farmers, 8 peasant women
7.4) Member flags (optional) = None are set.
Keep in mind that there can be at most six different troop stacks in a party template (the same is valid for a party declared in module_parties.py).
Parties are not to be confused with party templates. In the simplest terms, party templates are a set of guidelines from which parties on the map are spawned. This marks the most notable difference between parties and party templates - parties are unique entities on the map, whereas templates do not physically exist in the game world. They serve only as a list of guidelines from which to spawn parties. Therefore, certain operations that use a party_id for input will not work when they are fed a party_template_id.
Parties that are spawned from a template do not have to be unique. There can be many parties of the same template; each will have a random number of troops depending on the player's level and the minimum or maximum troop limits defined in the template.
If you've followed the documentation since the beginning, you should be fairly adept at reading tuples by this point and you will have noticed the one field in this tuple that's unlike any other field we've encountered before: Field number 6, the Personality flags field.
As mentioned in the tuple breakdown, the Personality field determines party behaviour on the map. Here you can assign custom scores for Courage and Aggressiveness, or use one of the preset personalities such as merchant_personality. These presets are constants, each containing a Courage and an Aggressiveness score. The presets are all defined in header_parties.py, so you can open that file now and scroll to the bottom to see the constant definitions for yourself. You find them also listed hereinafter. There you will also notice the list of possible Courage and Aggressiveness settings.
The constant merchant_personality is used in many templates throughout the file. Parties with this personality will be friendly, they will not go out to attack the enemy or raid weaker parties. This is because merchant_personality sets the party's Aggressiveness to aggresiveness_0. A party with aggresiveness_0 will never attack another party, whereas normal combative parties with the preset soldier_personality will have aggresiveness_8. This will let them attack other parties if the attackers' faction is on bad terms with the defenders' faction, and if the would-be attackers aren't badly outnumbered.
Courage is the score that determines when parties will run away from another, larger party. Higher Courage means they will be less quick to turn away when the numbers aren't entirely favorable. merchant_personality parties have a Courage of 8, where soldier_personality have a Courage of 11.
These settings scale from 0 to 15, allowing you to precisely set the desired behavior for your party templates. New modders, however, are recommended to stick with the presets. They cover the full range of personalities you should need for your first mod.
Finally, for bandit templates, there is the flag banditness. This causes the bandit party to constantly consider other nearby parties as prey, and if the prey is carrying significant amounts of gold and/or trade goods, the bandit party will attack. Ideally, a bandit party should have low aggressiveness or low troop numbers so that it does not attack soldier parties. NOTE: You may not see the banditness flag directly used at party templates but it is listed in headers_parties.py as part of bandit_personality.
The exact functionality of aggressiveness/courage scores (as well as things like 'banditness') on whether parties will approach one another or run away is hard-coded and can therefore not be altered, as is the pathfinding of AI parties.[1]
List of available settings:
Following predefined personality constants are given, you are free to add your own behind them.
soldier_personality = aggressiveness_8 | courage_9
merchant_personality = aggressiveness_0 | courage_7
escorted_merchant_personality = aggressiveness_0 | courage_11
bandit_personality = aggressiveness_3 | courage_8 | banditness
You can of course create new party templates. For easiest insurance that they will be used correctly, define a new slot_faction_reinforcements_YOURLETTER slot in module_constants.py. Populate it then in the script "initialize_faction_troop_types" with the others and call it in the appropriate reinforcement scripts. A quick search for slot_faction_reinforcements_a in module_scripts.py will show you the places you need to edit. There are not many, and other than declaring the slot in constants and creating the new template(s), that is the only file that needs editing by you.[2]